#include <iostream>
#include <fstream>
#include "../Finder.h"


int main(int argc, char * argv[]) {
	if (argc == 2) {
		SearchEnginer::Finder sf;
		
		std::fstream os;
		os.open("basic1.dic", std::fstream::in);
		os >> sf;
		os.close();

		std::fstream text;
		text.open(argv[1], std::fstream::in);
		
		std::string str;
		std::string temp="";
		while(!text.eof()) {
		   text >> str;
		   for(std::string::iterator itr = str.begin(); itr != str.end(); ++itr) {
		      if ((*itr) >= 'A' && (*itr) <='Z') *itr = *itr - 'A' + 'a';
		      if (*itr >= 'a' && *itr <='z') {  
		      	 temp.push_back(*itr);
		      } else {
		         if (temp != "") sf.append(temp);
		         temp = "";
		      } 
		      
		   }
		   if (temp != "") {
		      sf.append(temp);
		      temp = "";
		   } 
		}
		
		text.close();



        os.open("basic1.dic",  std::fstream::out | std::fstream::trunc );
	    os << sf;
    	os.close();
    }

}


